define([
  'jquery',
  'jqueryui',
  'underscore',
  'backbone',
  'lightboxme',
  'dateformatter',
  'multiselect',
  'multiselectfilter',
  'ckeditor',
  'models/appointment/DoctorReadOnlyModel',
  'text!templates/appointments/doctorReadOnlyAppointmentTemplate.html'
], function($, JQueryUI,_, Backbone,LightBoxMe,Dateformatter,Multiselect,Multiselectfilter,ck, DoctorReadOnlyModel, appointmentTemplate){

  var DoctorReadOnlyView = Backbone.View.extend({
    el: $(".mainpanel"),
    events: {} ,
    render: function(appointment){
    	this.model = new DoctorReadOnlyModel({id: appointment.get("id") })
    	console.log(this.model.url());
        var lOptions = {};
        var self=this;
        lOptions.success = function(){
            var data = {
            		appointment: appointment,
          		  	examinations: self.model.get('examinations'),
          	        _: _ 
          	      };
   		      self.loadTemplate(data);
           

        };

        this.model.fetch(lOptions);


    },
    loadTemplate: function(data){
	      var compiledTemplate = _.template( appointmentTemplate, data );
	      this.$el.html(compiledTemplate);
}
  });

  return DoctorReadOnlyView;
});
